package com.cy.Web;

import Pojo.JesonResult;
import Util.PageUtil;
import com.cy.Service.SysRoleService;
import com.cy.pojo.SysRole;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/role/")
@RestController
public class SysRoleController {
    @Autowired
    private SysRoleService sysRoleService;
    @GetMapping("chekcroles")
    public JesonResult doSelectCheckRoles(){
        return new JesonResult(sysRoleService.selectCheckRoles());
    }
    @GetMapping("{id}")
    public JesonResult doSelectByIdRoles(@PathVariable Integer id){
        return new JesonResult(sysRoleService.selectById(id));
    }
    @PutMapping
    public JesonResult doUpdateRoles(@RequestBody SysRole role){
        sysRoleService.updateRole(role);
        return new JesonResult("Update OK");
    }
    @PostMapping
    public JesonResult doInsertRoles(SysRole role){
        sysRoleService.insertRole(role);
        return new JesonResult("Insert OK");
    }

    @GetMapping
    public JesonResult doFindRoles(SysRole role){
        return new JesonResult(PageUtil.startPage()
                                   .doSelectPageInfo(
                                           ()->sysRoleService.insertRole(role))
                                );
    }
}
